package inner_class.anonymous_inner_class;

/**
 * @Package: inner_class.anonymous_inner_class
 * @ClassName: AnonymousInnerClassExercise
 * @Author: x2606
 * @CreateTime: 2022/3/12 12:46
 * @Description: 匿名内部类实践  匿名内部类传参
 */

public class AnonymousInnerClassExercise {
    public static void main(String[] args) {
        C c = new C();
        //如果这个类只使用一次，就可以不单独写类来实现接口，
        c.showB(new B() {
                    @Override
                    public void show() {
                        System.out.println("匿名内部类传参");
                    }
                }
        );
    }
}

interface B{
    public void show();
}

class C{
    public void showB(B b){
        b.show();
    }
}

